import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import * as Cesium from 'cesium'

export const useEarthStore = defineStore('Earth', () => {
    const viewer = ref<typeof Cesium>()

    window.viewer = viewer;
    // 初始化地图对象
    const initViewer = (view:typeof Cesium,flag?:boolean)=>{
        if(flag){
            viewer.value = view;
        }else{
            !viewer.value && (viewer.value = view);
        }
    }

    const getViewer = ()=>{
        return viewer.value || null;
    }
  
    return { initViewer, getViewer }
  })